package com.zt.ztzx.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zt.ztzx.model.entity.product.Category;
import com.zt.ztzx.model.vo.common.Result;
import com.zt.ztzx.service.CategoryService;
import com.zt.ztzx.mapper.CategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;

/**
* @author 16236
* @description 针对表【category(商品分类)】的数据库操作Service实现
* @createDate 2024-08-23 10:43:09
*/
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category>
    implements CategoryService{

    @Autowired
    private CategoryMapper categoryMapper;

    /**
     * 查询所有分类
     * @param category
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public Result<PageInfo<Category>> findAll(Category category, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Category> list = categoryMapper.findAll(category);
        PageInfo<Category> pageInfo = new PageInfo<>(list);
        return Result.build(pageInfo,200,"查询成功");
    }

    @Override
    public Result removeData(Integer id) {
        int i = categoryMapper.deleteByCId(id);
        return Result.build(i,200,"删除成功");
    }
}




